#!/usr/bin/env python

###############################################################################
#
#
###############################################################################

#
# MODULES
#
import sys
import os
import re
import glob
import string

#from numarray import *
from pylab import *
#import Numeric

#
# ARGUMENTS
#

if len(sys.argv) < 3:
    print 'Usage: %s <past> <future>' % sys.argv[0]
    raise SystemExit
else:
    pastfilename = sys.argv[1]
    futurefilename = sys.argv[2]

# max wind speed range and bin size
minval = 10
maxval = 75
step = 5

pastbins = arange(minval-step/2, maxval-step/2, step);
futurebins = arange(minval, maxval, step);
nbins = size(pastbins)

numstorms = 0
pastvals = []
futurevals = []

# loop through data files
f = open(pastfilename, 'r')
for index,line in enumerate(f):
    elems = string.split(line)
    val = float(elems[5]) # max wind speed is in 6th column

    pastvals.append(val)
    numstorms += 1
f.close()

f = open(futurefilename, 'r')
for index,line in enumerate(f):
    elems = string.split(line)
    val = float(elems[5]) # max wind speed is in 6th column

    futurevals.append(val)
    numstorms += 1
f.close()

# histogram both
figure(1)
hold(True)
pastpdf, pastbins1, pastpatches = hist(pastvals,pastbins,False)
futurepdf, futurebins1, futurepatches = hist(futurevals,futurebins,False)

for p in pastpatches:
    p.set_facecolor('r') 
    p.width = p.width / 3
    
for p in futurepatches:
    p.width = p.width / 3
    p.set_facecolor('b')

legend((pastpatches[0],futurepatches[0]),('Past','Future'))
title('Max Wind Speed (m/s)')

#axis([0.0, 75.0, 0.0, 0.04])

    
show()
